package com.csx.base.design.behavior.memento;

/**
 * @author cuisongxu
 * @date 2022/10/9 12:03
 */
public class Doc {

    /**
     * 文档标题
     */
    private String title;

    /**
     * 文档内容
     */
    private String body;

    public Doc(String title) {
        // 新建文档先命名
        this.title = title;
        // 新建的文档内容为空
        this.body = "";
    }

    public History createHistory() {
        // 创建历史记录
        return new History(body);
    }

    public void restoreHistory(History history) {
        // 恢复历史记录
        this.body = history.getBody();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }
}
